<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>flex box按比例布局</title>
    <style>
        body {
            padding: 0;
            margin: 0;
            color: #c0c0c0;
            font-family: verdana;
        }

        .layers {
            position: relative;
            top: 0;
            max-width: 960px;
            min-width: 320px;
            height: 100vh;
            margin: 0 auto;
        }

        .layer {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        .grid {
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
        }

        .grid__column {
            -webkit-box-flex: 1;
            -webkit-flex-grow: 1;
            -ms-flex-positive: 1;
            flex-grow: 1;
            -webkit-flex-shrink: 1;
            -ms-flex-negative: 1;
            flex-shrink: 1;
            margin: 0 10px;
            background: #fbfbfb;
            border-left: 1px dashed #c0c0c0;
            border-right: 1px dashed #c0c0c0;
        }

        .row {
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
        }

        .row__item {
            -webkit-box-flex: 1;
            -webkit-flex-grow: 1;
            -ms-flex-positive: 1;
            flex-grow: 1;
            -webkit-flex-shrink: 1;
            -ms-flex-negative: 1;
            flex-shrink: 1;
            -webkit-flex-basis: 0;
            -ms-flex-preferred-size: 0;
            flex-basis: 0;
            margin: 10px;
            padding: 10px 0;
            text-align: center;
            border: 1px solid #c0c0c0;
            border-radius: 4px;
            background: #fff;
        }

        .row__item--double {
            -webkit-box-flex: 2;
            -webkit-flex-grow: 2;
            -ms-flex-positive: 2;
            flex-grow: 2;
            -webkit-flex-shrink: 2;
            -ms-flex-negative: 2;
            flex-shrink: 2;
            -webkit-flex-basis: 22px;
            -ms-flex-preferred-size: 22px;
            flex-basis: 22px;
        }
    </style>
</head>
<body>
<section class="layers">
    <div class="grid layer">
        <div class="grid__column"></div>
        <div class="grid__column"></div>
        <div class="grid__column"></div>
        <div class="grid__column"></div>
        <div class="grid__column"></div>
        <div class="grid__column"></div>
        <div class="grid__column"></div>
        <div class="grid__column"></div>
        <div class="grid__column"></div>
        <div class="grid__column"></div>
        <div class="grid__column"></div>
        <div class="grid__column"></div>
    </div>
    <div class="rows layer">
        <!-- row 1 -->
        <div class="row">
            <div class="row__item">1/2</div>
            <div class="row__item">1/2</div>
        </div>
        <!-- row 2 -->
        <div class="row">
            <div class="row__item">1/3</div>
            <div class="row__item">1/3</div>
            <div class="row__item">1/3</div>
        </div>
        <!-- row 3-->
        <div class="row">
            <div class="row__item">1/4</div>
            <div class="row__item">1/4</div>
            <div class="row__item">1/4</div>
            <div class="row__item">1/4</div>
        </div>
        <!-- row 4 -->
        <div class="row">
            <div class="row__item">1/6</div>
            <div class="row__item">1/6</div>
            <div class="row__item row__item--double">2/6</div>
            <div class="row__item">1/6</div>
            <div class="row__item">1/6</div>
        </div>
        <!-- row 5 -->
        <div class="row">
            <div class="row__item row__item--double">2/3</div>
            <div class="row__item">1/3</div>
        </div>
        <!-- row 6 -->
        <div class="row">
            <div class="row__item row__item--double">1/2</div>
            <div class="row__item">1/4</div>
            <div class="row__item">1/4</div>
        </div>
        <!-- row 7 with nesting -->
        <div class="row">
            <div class="row__item">1/4</div>
            <div class="row__item">1/4</div>
            <div class="row__item row__item--double">
                1/2
                <div class="row">
                    <div class="row__item">1/4</div>
                    <div class="row__item">1/4</div>
                    <div class="row__item">1/4</div>
                    <div class="row__item">1/4</div>
                </div>
            </div>
        </div>
    </div>
</section>
</body>
</html>